package com.starlight.ts_clouddev.controller;

import com.starlight.ts_clouddev.infrastructure.entity.CloudUserRole;
import com.starlight.ts_clouddev.service.CloudUserRoleService;
import com.starlight.ts_clouddev.util.CloudResponse;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author yfy2001
 * @date 2023/5/18 15:11
 */
@RestController
@RequestMapping("/userRole")
public class CloudUserRoleController {

    @Resource
    private CloudUserRoleService cloudUserRoleService;

    @PostMapping("/create")
    public CloudResponse<Boolean> create(CloudUserRole cloudUserRole){
        return CloudResponse.success(cloudUserRoleService.save(cloudUserRole));
    }

    @PostMapping("/update")
    public CloudResponse<Boolean> update(CloudUserRole cloudUserRole){
        return CloudResponse.success(cloudUserRoleService.updateById(cloudUserRole));
    }

    @GetMapping("/read")
    public CloudResponse<List<CloudUserRole>> read(){
        return CloudResponse.success(cloudUserRoleService.list());
    }

    @PostMapping("/delete")
    public CloudResponse<Boolean> delete(CloudUserRole cloudUserRole){
        return CloudResponse.success(cloudUserRoleService.removeById(cloudUserRole));
    }
}
